articles

Home / DeveloperSection / Articles / Create Private Assembly Application in C#

Create Private Assembly Application in C#

Create Private Assembly Application in C#

Anonymous User1970 05-Jul-2021

Let's see the how can make the Private assembly and use it :

Step 1 : Open Visual Studio 2019 on your machine create a class file with a valid Class name(In my project I've named it 'PAssembly'). Now click next after completing and your new project will successfully created.
Step 2 : Now start writing the basic code. In my scenario I've created one constructor and one function in which I've print some sort of normal message.
using System;
namespace PAssembly
{
    public class PrivateAssembly
    {
        public PrivateAssembly()
        {
            Console.WriteLine('Private Assembly Called');
        }
        public void privateAssemblyFunc()
        {
            Console.WriteLine('Private Assembly Function Called');
        }
    }
}


Step 3 : After completing with these codes build the code by just pressing the shortcut key on your keyboard 'Ctrl+Shift+B' or you can go to the Build in menu bar and create by clicking on Build Solution. Now your DLL file will be created.
Step 4 : Create a new Console Application by using shortcut key on your keyboard Ctrl+Shift+N or by go into the File in menu bar > New > Project.
Step 5 : Add dll file which you have created in your application by right click on the Project Name on Search Solution Explorer and add the reference by going on Add > Project Reference.
Step 6 : Now Add the Namespace at the top create an object of your Dll file and call the function which you have created in it.
using System;
using PAssembly;
namespace PrivateAssemblyApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            PrivateAssembly obj = new PrivateAssembly();
            obj.privateAssemblyFunc();
        }
    }
}

Step 7 : Now, press Ctrl+F5 on your keyboard or go to the Debug in the menu bar and click on 'Start without Debugging'. Now you'll see the Message which you have created in the Constructor or in a function of your Dll File in Console.


Now, You have successfully know use of the Private Assembly.


Updated 05-Jul-2021
I am a content writter !

Leave Comment

Comments

Liked By